#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
	int n = 0;
	scanf("%d", &n);
	int i = 3;
	int sum = 0;
	int min = 0;
	while (i--)
	{
		int pen, money = 0;
		scanf("%d%d", &pen, &money);
		sum = (n / pen) * money;
		if (n % pen != 0)
			sum += money;
		if (i == 2)
			min = sum;
		if (sum <= min)
			min = sum;
	}
	printf("%d", min);
	return 0;
}